package com.nervenets.web.redis.domain.admin;

import com.nervenets.web.enumeration.Role;
import com.nervenets.web.hibernate.domain.Manager;
import com.nervenets.web.redis.RedisSetDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class ManagerStored extends RedisSetDomain {
    private long managerId;
    private String mobile;
    private Role role;

    @Override
    public String getField() {
        return String.valueOf(managerId);
    }

    @Override
    public String getKey() {
        return String.format("M_V1_%s", String.format("%04d", managerId).substring(0, 4));
    }

    public ManagerStored(long managerId) {
        this.managerId = managerId;
    }

    public ManagerStored(Manager manager) {
        this.managerId = manager.getId();
        this.mobile = manager.getMobile();
        this.role = manager.getRole();
    }
}
